01.#include <iostream>   
02.using namespace std;   
03.  
04.unsigned Reverse(unsigned n)   
05.{   
06.    unsigned temp = n,m = 0;   
07.    while (temp)   
08.    {   
09.        m = 10 *m + temp % 10;   
10.        temp /= 10;   
11.    }   
12.    return m;   
13.}   
14.  
15.int main()   
16.{   
17.    int n;   
18.    scanf("%d",&n);   
19.    while (n--)   
20.    {   
21.        unsigned m,index = 0;   
22.        scanf("%u",&m);   
23.        while (m != Reverse(m))   
24.        {   
25.            index++;   
26.            m += Reverse(m);   
27.        }   
28.        printf("%u %u\n",index,m);   
29.    }   
30.    return 0;   
31.}  
